﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CuadroMandoIntegralFMCH
{
    public partial class ConfiguracionSQL : Form
    {
        public ConfiguracionSQL()
        {
            InitializeComponent();
        }

        private void ConfiguracionSQL_Load(object sender, EventArgs e)
        {
            showSavedConnectionSettings();
        }

        private void showSavedConnectionSettings()
        {
            SqlConnectionStringBuilder builder =
                new SqlConnectionStringBuilder(ConnectionStringManager.GetFirstConnectionString());
            cbServer.Text = builder.DataSource.ToUpper();
            cbDatabase.Text = builder.InitialCatalog.ToUpper();
            if (builder.IntegratedSecurity)
            {
                rbIntegratedSecurity.Checked = true;
                tbUser.Text = string.Empty;
                tbUser.Text = string.Empty;
            }
            else
            {
                rbSQLServerSecurity.Checked = true;
                tbUser.Text = builder.UserID;
                tbPassword.Text = builder.Password;
            }
        }
    }
}
